//
//  PlatformMessageCell.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/26.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "PlatformMessageCell.h"

@interface PlatformMessageCell ()

@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *contentLabel;

@end

@implementation PlatformMessageCell

+ (PlatformMessageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"PlatformMessageCell";
    PlatformMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[PlatformMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(20), ScreenX375(50), ScreenX375(50))];
    icon.image = ImageWithName(@"系统消息-通过");
    [self addSubview:icon];
    
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(78), ScreenX375(27), ScreenX375(90), ScreenX375(17))];
    nameLabel.text = @"系统消息";
    nameLabel.textColor = FONTCOLOR_BLACK;
    nameLabel.font = Kfont(15);
    [self addSubview:nameLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(78), ScreenX375(50), ScreenX375(100), ScreenX375(14))];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#888888");
    self.timeLabel.font = Kfont(12);
    self.timeLabel.text = @"10小时前";
    [self addSubview:self.timeLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(25), ScreenX375(81), SCREEN_WIDTH - ScreenX375(50), ScreenX375(16))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#212121");
    self.detailLabel.font = Kfont(14);
    self.detailLabel.text = @"管理员 审核通过了你发布的原创作品：《啦啦啦》";
    [self addSubview:self.detailLabel];
    
    self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(25), ScreenX375(107), SCREEN_WIDTH - ScreenX375(50), ScreenX375(15))];
    self.contentLabel.textColor = REXADECIMALCOLOR(@"#888888");
    self.contentLabel.font = Kfont(13);
    self.contentLabel.text = @"操作原因感谢在虾拼发布您的原创设计设计作品";
    [self addSubview:self.contentLabel];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(142) - 0.5, SCREEN_WIDTH - ScreenX375(32), 0.5)];
    line.backgroundColor = REXADECIMALCOLOR(@"#e4e4e4");
    [self addSubview:line];
}

- (void)setPlatformMessageModel:(PlatformMessageModel *)platformMessageModel {
    _platformMessageModel = platformMessageModel;
    
    if ([platformMessageModel.modifyTime class] != [NSNull class]) {
        self.timeLabel.text = [HttpManager getTime:[HttpManager TimeStamp:platformMessageModel.modifyTime]];
    }
    self.detailLabel.text = [NSString stringWithFormat:@"%@ %@",platformMessageModel.senderName,platformMessageModel.content];
    self.contentLabel.text = [NSString stringWithFormat:@"%@ %@",platformMessageModel.senderName,platformMessageModel.content];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation PlatformMessageModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id"
                                                                  }];
}


@end
